<{include file="../templates/admin/header.html"}>

<div class="main-div">
<form name="theForm" method="post" action="manager.php<{if $action neq ''}>?act=<{$action}><{/if}>" enctype="multipart/form-data" onsubmit="return validate();">
<table width="100%">
  <tr>
    <td class="label">用户名</td>
    <td>
      <input type="text" name="username" maxlength="20" value="<{$user.username|escape}>" size="34"/><{$lang.require_field}></td>
  </tr>
  <tr>
    <td class="label">Email地址</td>
    <td>
      <input type="text" name="email" value="<{$user.email|escape}>" size="34" /><{$lang.require_field}></td>
  </tr>
  
  
  <tr>
    <td class="label">密码</td>
    <td>
      <input type="password" name="password" maxlength="32" size="34" /><{$lang.require_field}></td>
  </tr>
  <tr>
    <td class="label">确认密码</td>
    <td>
      <input type="password" name="pwd_confirm" maxlength="32" size="34" /><{$lang.require_field}></td>
  </tr>

<!-- 
  <{if $judge neq "add"}>
  <tr>
    <td class="label">新密码</td>
    <td>
      <input type="password" name="new_password" maxlength="32" size="34" /></td>
  </tr>
  <tr>
    <td class="label">确认密码</td>
    <td>
      <input type="password" name="pwd_confirm" value="" size="34" /></td>
  </tr>
  <{/if}>
-->
  
   <tr>
   <td class="label">角色选择</td>
    <td>
      <select name="select_role">
        <option value="" selected="selected" >请选择...</option>
        <{foreach from=$role_list item=list}>
        <option value="<{$list.role_id}>" ><{$list.role_name}></option>
        <{/foreach}>
      </select>
    </td>
  </tr>

<!-- 
  <{if $action eq "modif"}>
  <tr>
  <td align="left" class="label"><{$lang.edit_navi}></td>
  <td>
      <table style="width:300px" cellspacing="0">
        <tr>
        <td valign="top">
          <input type="hidden" name="nav_list[]" id="nav_list[]" />
          <select name="menus_navlist" id="menus_navlist" multiple="true" style="width: 120px; height: 180px" onclick="setTimeout('toggleButtonSatus()', 1);">
          <{html_options options=$nav_arr}>
          </select></td>
        <td align="center">
         <input type="button" class="button" value="<{$lang.move_up}>" id="btnMoveUp" onclick="moveOptions('up')" disabled="true" />
         <input type="button" class="button" value="<{$lang.move_down}>" id="btnMoveDown" onclick="moveOptions('down')" disabled="true" />
         <input type="button" value="<{$lang.add_nav}>" id="btnAdd" onclick="JavaScript:addItem(theForm.all_menu_list,theForm.menus_navlist); this.disabled=true; " class="button" disabled="true" /><br />
         <input type="button" value="<{$lang.remove_nav}>" onclick="JavaScript:delItem(theForm.menus_navlist); toggleButtonSatus()" class="button" disabled="true" id="btnRemove" /></td>
        <td>
          <select id="all_menu_list" name="all_menu_list" size="15" multiple="true" style="width:150px; height: 180px" onchange="toggleAddButton()">
            <{foreach from=$menus item=menu key=key}>
              <{if $key neq "admin_home" && $menus.$key}>
              <option value="" style="font-weight:bold;"><{$lang.$key}></option>
              <{foreach from=$menus.$key item=item key=k}>
              <option value="<{$item}>">&nbsp;&nbsp;&nbsp;&nbsp;<{$lang.$k}></option>
              <{/foreach}>
              <{/if}>
             <{/foreach}>
           </select></td>
        </tr>
      </table></td>
  </tr>
  <{/if}>
 -->
  <tr>
    <td colspan="2" align="center">
      <input type="submit" value="确定" class="button" />&nbsp;&nbsp;&nbsp;
      <input type="reset" value="重置" class="button" />
      <input type="hidden" name="id" value="<{$user.user_id}>" /></td>
  </tr>
</table>
</form>
</div>

<script language="JavaScript">
var action = "<{$action}>";
<!--
{literal}
document.forms['theForm'].elements['username'].focus();
onload = function()
{
    // ��ʼ��鶩��
    startCheckOrder();
}

/**
 * �л����Ӱ�ť��״̬
 */
function toggleAddButton()
{
	var sel = document.getElementById("all_menu_list");
	document.getElementById("btnAdd").disabled = (sel.selectedIndex > -1) ? false : true;
}

/**
 * �л��Ƴ������ƣ����ư�ť״̬
 */
function toggleButtonSatus()
{
	var sel = document.getElementById("menus_navlist");
	document.getElementById("btnRemove").disabled = (sel.selectedIndex > -1) ? false : true;
	document.getElementById("btnMoveUp").disabled = (sel.selectedIndex > -1) ? false : true;
	document.getElementById("btnMoveDown").disabled = (sel.selectedIndex > -1) ? false : true;
}

/**
 * �ƶ�ѡ�����б���
 */
function moveOptions(direction)
{
	var sel = document.getElementById('menus_navlist');
	if (sel.selectedIndex == -1)
	{
		return;
	}

	len = sel.length
	for (i = 0; i < len; i++)
	{
	if (sel.options[i].selected)
	{
	if (i == 0 && direction == 'up')
	{
	return;
	}

	newOpt = sel.options[i].cloneNode(true);

	sel.removeChild(sel.options[i]);
	tarOpt = (direction == "up") ? sel.options[i-1] : sel.options[i+1]
	sel.insertBefore(newOpt, tarOpt);
	newOpt.selected = true;
	break;
	}
	}
	}

	/**
	* ���?��������
	*/
	function validate()
	{
	get_navlist();

	validator = new Validator("theForm");
	validator.password = function (controlId, msg)
	{
	var obj = document.forms[this.formName].elements[controlId];
	obj.value = Utils.trim(obj.value);
	if (!(obj.value.length >= 6 && /\d+/.test(obj.value) && /[a-zA-Z]+/.test(obj.value)))
	{
	this.addErrorMsg(msg);
	}

	}

	validator.required("username", username_empty);
	validator.required("email", email_empty, 1);
	validator.isEmail("email", email_error);

	if (action == "add")
	{
	if (document.forms['theForm'].elements['password'])
	{
	validator.password("password", password_invaild);
	validator.eqaul("password", "pwd_confirm", password_error);
	}
  }
  if (action == "edit" || action == "modif")
  {
  if (document.forms['theForm'].elements['old_password'].value.length > 0)
  {
  validator.password("new_password", password_invaild);
  		validator.eqaul("new_password", "pwd_confirm", password_error);
  }
  }

  				return validator.passed();
  }

  function get_navlist()
  {
  if (!document.getElementById('nav_list[]'))
  {
    return;
  }

  document.getElementById('nav_list[]').value = joinItem(document.getElementById('menus_navlist'));
  //alert(document.getElementById('nav_list[]').value);
  }
  //-->
  {/literal}
</script>